###### 本工程参照 external/opencv ######
LOCAL_PATH := $(call my-dir)

MY_CPP_STL_INCLUDES := 	\
	$(TOP)/prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++/include \
	$(TOP)/prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++/libs/armeabi/include
MY_CPP_STL_LIBS := \
	$(TOP)/prebuilts/ndk/current/sources/cxx-stl/gnu-libstdc++/libs/armeabi/libgnustl_static.a

MY_SQLITE3_INCLUDES := \
	$(TOP)/external/sqlite/dist

MY_CPP_CFLAGS := -DOS_ANDROID -DPRODUCT_ABC -frtti -fexceptions

#############################################
######  libcjson
#############################################
include $(CLEAR_VARS)
MY_SRC_DIR := $(LOCAL_PATH)/opensource/libcjson/cJSON
LOCAL_MODULE := libcjson

#LOCAL_LDLIBS += -lstdc++  ###不支持rtti和exception
LOCAL_LDFLAGS += $(MY_CPP_STL_LIBS)

LOCAL_C_INCLUDES := \
		$(MY_SRC_DIR)

LOCAL_SRC_FILES := 	\
	opensource/libcjson/cJSON/cJSON.c

include $(BUILD_STATIC_LIBRARY)

#############################################
######  libconfig
#############################################
include $(CLEAR_VARS)
MY_SRC_DIR := $(LOCAL_PATH)/opensource/libconfig++/libconfig-1.4.9
LOCAL_MODULE := libconfig

LOCAL_CFLAGS := -DLIBCONFIG_STATIC $(MY_CPP_CFLAGS)
LOCAL_CXXFLAGS := $(LOCAL_CFLAGS)

#LOCAL_LDLIBS += -lstdc++  ###不支持rtti和exception
LOCAL_LDFLAGS += $(MY_CPP_STL_LIBS)

LOCAL_C_INCLUDES := \
	$(MY_SRC_DIR) \
	$(MY_CPP_STL_INCLUDES)

LOCAL_SRC_FILES :=	\
	opensource/libconfig++/libconfig-1.4.9/grammar.c \
	opensource/libconfig++/libconfig-1.4.9/libconfig.c \
	opensource/libconfig++/libconfig-1.4.9/libconfigcpp.h \
	opensource/libconfig++/libconfig-1.4.9/libconfigcpp.cpp \
	opensource/libconfig++/libconfig-1.4.9/scanctx.c \
	opensource/libconfig++/libconfig-1.4.9/scanner.c \
	opensource/libconfig++/libconfig-1.4.9/strbuf.c

include $(BUILD_STATIC_LIBRARY)


#############################################
######  libtinyalsa
#############################################
include $(CLEAR_VARS)
MY_SRC_DIR := $(LOCAL_PATH)/opensource/libtinyalsa/tinyalsa
LOCAL_MODULE := libtinyalsa

LOCAL_CFLAGS := -DLIBCONFIG_STATIC $(MY_CPP_CFLAGS)
LOCAL_CXXFLAGS := $(LOCAL_CFLAGS)

#LOCAL_LDLIBS += -lstdc++  ###不支持rtti和exception
LOCAL_LDFLAGS += $(MY_CPP_STL_LIBS)

LOCAL_C_INCLUDES := \
	$(MY_SRC_DIR) \
	$(MY_CPP_STL_INCLUDES)
	
LOCAL_SRC_FILES := \
	opensource/libtinyalsa/tinyalsa/control.c \
	opensource/libtinyalsa/tinyalsa/mixer.c \
	opensource/libtinyalsa/tinyalsa/pcm.c
include $(BUILD_STATIC_LIBRARY)

#############################################
######  libemb
#############################################
include $(CLEAR_VARS)

MY_SRC_DIR := $(LOCAL_PATH)/opensource/libemb
LOCAL_MODULE := libemb

LOCAL_CFLAGS := -DOS_UNIXLIKE $(MY_CPP_CFLAGS)
LOCAL_CXXFLAGS := $(LOCAL_CFLAGS)

#LOCAL_LDLIBS := -lstdc++  ###不支持rtti和exception
LOCAL_LDFLAGS += $(MY_CPP_STL_LIBS)
LOCAL_STATIC_LIBRARIES :=
LOCAL_SHARED_LIBRARIES := 

LOCAL_C_INCLUDES := \
	$(MY_SRC_DIR)/ \
	$(MY_CPP_STL_INCLUDES) \
	$(MY_SQLITE3_INCLUDES)
	
LOCAL_SRC_FILES := \
	opensource/libemb/ArgUtil.cpp \
	opensource/libemb/BaseType.cpp \
	opensource/libemb/ComUtil.cpp

include $(BUILD_STATIC_LIBRARY)

#############################################
######  tracerclient
#############################################
include $(CLEAR_VARS)
MY_SRC_DIR := $(LOCAL_PATH)/app/demo
LOCAL_MODULE := demo

LOCAL_CFLAGS += $(MY_CPP_CFLAGS)
LOCAL_CXXFLAGS := $(LOCAL_CFLAGS)
#LOCAL_LDFLAGS += $(MY_CPP_STL_LIBS)	##在native_app.mk中已经定义

LOCAL_STATIC_LIBRARIES := libemb

LOCAL_C_INCLUDES := \
	$(MY_SRC_DIR)/ \
	$(MY_SRC_DIR)/../opensource/libemb

LOCAL_SRC_FILES := \
	app/demo/demo.cpp

include $(BUILD_NATIVE_APP)


#############################################
######  配置文件预置
#############################################
$(warning force copy files:$(LOCAL_MODULE_PATH))
$(shell chmod 777 $(LOCAL_PATH)/app/android.startapp)
$(shell cp -rf $(LOCAL_PATH)/app/android.startapp $(LOCAL_MODULE_PATH)/startapp)

